import tools as Tools
import data as Data

screen = Tools.screen
Actor = Tools.Actor
Animation = Tools.Animation

class User:
    def __init__(self):
        import tkinter
        import ttkbootstrap as ttk
        self.Root = tkinter.Tk()
        self.Root.geometry('500x520')
        self.Lable1 = ttk.Label(self.Root,text='图一')
        self.Entry1 = ttk.Entry(self.Root)
        self.Lable2 = ttk.Label(self.Root,text='图二')
        self.Entry2 = ttk.Entry(self.Root)
        self.Lable3 = ttk.Label(self.Root,text='图三')
        self.Entry3 = ttk.Entry(self.Root)
        self.Button = ttk.Button(self.Root,text='提交',command=self.Judgment)
        self.Lable4 = ttk.Label(self.Root, text=' ')
    def TryThisButtonCommand(self):
        self.Lable1.pack(); self.Entry1.pack()
        self.Lable2.pack(); self.Entry2.pack()
        self.Lable3.pack(); self.Entry3.pack()
        self.Button.pack(); self.Lable4.pack()
        self.Root.mainloop()
    def Judgment(self):
        pic1 = self.Entry1.get()
        pic2 = self.Entry2.get()
        pic3 = self.Entry3.get()
        if pic1 == '线段' and pic2 == '射线' and pic3 == '直线':
            Tools.Debug(1,'回答正确')
            self.Lable4.configure(text='很好，接着往下去看看吧.',foreground='green')
        else: 
            Tools.Debug(1,'回答错误')
            self.Lable4.configure(text='再试试？',foreground='red')
            
class Main:
    def __init__(self):
        Tools.Debug(3,'Part2')
    def Enter(self):
        self.TryThisButton = Actor('try_this',[Tools.CentralX(),Data.HEIGHT+150])
        self.LineSegment = Actor('line_segment',[-150,Tools.CentralY()-100])
        self.Ray = Actor('ray',[Data.WIDTH+150,Tools.CentralY()])
        self.StraightLine = Actor('straight_line',[-150,Tools.CentralY()+100])

        Animation(self.TryThisButton,'accel_decel',1,None,y=Data.HEIGHT-150)
        Animation(self.LineSegment,'accel_decel',2,None,x=Tools.CentralX())
        Animation(self.Ray,'accel_decel',3,None,x=Tools.CentralX())
        Animation(self.StraightLine,'accel_decel',4,None,x=Tools.CentralX())
    def Update(self):
        screen.fill((0,0,0))

        screen.draw.text("在开始之前，让我们先来复习一下.",(100,100),"osans4.ttf")
        screen.draw.text("点可以连成线，你能分别说出它们的几何学名称吗？",(100,150),"osans4.ttf")
        self.LineSegment.draw()
        self.Ray.draw()
        self.StraightLine.draw()
        self.TryThisButton.draw()
    def Touch(self,pos):
        if self.TryThisButton.collidepoint(pos):
            User().TryThisButtonCommand()